-module(packet_dispatch).
-include("protocol.hrl").
-export[do/2,protocol_lookup/2].

do(unknown, _) ->
	ignore;
	
do(sctp_packet, Packet_Tuple) ->
	sctp_pair_dispatcher:do(packet_comming,Packet_Tuple);

do(gtpc_packet, Packet_Tuple) ->
	gtp_bearer_dispatcher:do(packet_comming,Packet_Tuple);
	
do(lwapp_packet,Packet_Tuple) ->
	lwapp_tunnel_dispatcher:do(packet_comming,Packet_Tuple);
	
do(udp_packet, Packet_Tuple) ->
	udp_packet_fun:parse(Packet_Tuple);
	
do(l2_packet, Packet_Tuple) ->
	l2_packet_fun:parse(Packet_Tuple);
	
do(ip_packet, Packet_Tuple) ->
	ip_parser:parse(Packet_Tuple).
	
protocol_lookup(ip_protocol,17) ->
	udp_packet;
protocol_lookup(ip_protocol,132) ->
	sctp_packet;
protocol_lookup(udp_protocol,Port_Info) ->
	case Port_Info of
	{?GTP_C,_} ->
		gtpc_packet;
	{_,?GTP_C} ->
		gtpc_packet;
	{?LWAPP,_} ->
		lwapp_packet;
	{SPort,DPort} ->
		error_logger:info_report([{unrecognized_port,Port_Info}]),
		unknown
	end;
protocol_lookup(A,_) ->
	error_logger:info_report([{unrecognozed_prot,A}]),
	unknown.
